home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / ispell40.lha / ispell-4.0 / expand.c < prev    next >
C/C++ Source or Header  |  1993-05-31  |  2KB  |  75 lines

  1. /* Copyright (C) 1990, 1993 Free Software Foundation, Inc.
  2.  
  3.    This file is part of GNU ISPELL.
  4.  
  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 2, or (at your option)
  8.    any later version.
  9.  
  10.    This program is distributed in the hope that it will be useful,
  11.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.    GNU General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with this program; if not, write to the Free Software
  17.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. /* this program takes a dictionary with flags on the standard input,
  20.    and expands them onto the standard output. */
  21.  
  22. #include <stdio.h>
  23. #include <ctype.h>
  24. #include "ispell.h"
  25. #include "hash.h"
  26. #include "good.h"
  27.  
  28. /* this array contains letters to use when generating near misses */
  29. char near_miss_letters[256];
  30. int nnear_miss_letters;
  31.  
  32. /* this array has 1 for any character that is in near_miss_letters */
  33. char near_map[256];
  34.  
  35. char buf[BUFSIZ];
  36.  
  37. int
  38. main (argc, argv)
  39.   int argc;
  40.   char **argv;
  41. {
  42.   FILE *in;
  43.   int i, n;
  44.   char *p;
  45.  
  46.   argc--;
  47.   argv++;
  48.  
  49.   if (argc)
  50.     {
  51.       if ((in = fopen (*argv, "r")) == NULL)
  52.     {
  53.       (void) fprintf (stderr, "can't open %s\n", *argv);
  54.       exit (1);
  55.     }
  56.     }
  57.   else
  58.     {
  59.       in = stdin;
  60.     }
  61.  
  62.   while (fgets (buf, sizeof buf, in) != NULL)
  63.     {
  64.       if ((p = (char *) strchr (buf, '\n')))
  65.     *p = 0;
  66.  
  67.       downcase (buf, buf);
  68.       n = expand (buf);
  69.       for (i = 0; i < n; i++)
  70.     puts (words[i]);
  71.     }
  72.  
  73.   return 0;
  74. }
  75.